package day11.Test2;

public class Test2 {
    public static void main(String[] args) {
        Boo b1 = new Boo();
        //子类可以调用父类的变量和方法 —— 继承
        b1.n = 100;//本
        b1.x = 20;//父
        b1.bTest();
        b1.aTest();

        //父类只能调用父类的变量和方法
        Aoo a1 =new Aoo();
        a1.x = 20;
        a1.aTest();

        //向上造型
        Aoo a2 = new Boo();
        a2.aTest();

    }
}
class Aoo{
    int x;
    public void aTest(){
        System.out.println("父");
    }
}

class Boo extends Aoo{
    int n;
    public void bTest(){
        System.out.println("子");
    }
}
